package com.hksj.drcs.controller;

import com.hksj.common.core.model.Rest;
import com.hksj.drcs.query.CockpitQuery;
import com.hksj.drcs.service.DrcsCockpitService;
import com.hksj.drcs.vo.ControlDeviceNumVO;
import com.hksj.drcs.vo.ControlDeviceOverviewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author zengke
 * @version 1.0
 * @see DrcsCockpitController
 * @since 2025/06/05 15:18
 */

@Api(tags = "设备远程控制-驾驶舱")
@RestController
@RequestMapping("/api/drcs/cockpit")
public class DrcsCockpitController {

    @Autowired
    @Qualifier(value = "drcsCockpitServiceImpl")
    private DrcsCockpitService drcsCockpitService;

    @ApiOperation(value = "查询控制设备列表")
    @PostMapping("/queryControlDeviceOverviewList")
    public Rest<List<ControlDeviceOverviewVO>> queryControlDeviceOverviewList(@RequestBody CockpitQuery query){
        List<ControlDeviceOverviewVO> controlDeviceOverviewVO = drcsCockpitService.queryControlDeviceOverview(query);
        return Rest.ok(controlDeviceOverviewVO);
    }

    @ApiOperation(value = "查询控制设备数量列表")
    @PostMapping("/queryControlDeviceNumList")
    public Rest<List<ControlDeviceNumVO>> queryControlDeviceNumList(@RequestBody CockpitQuery query){
        List<ControlDeviceNumVO> controlDeviceNumList = drcsCockpitService.queryControlDeviceNumList(query);
        return Rest.ok(controlDeviceNumList);
    }

    @ApiOperation(value = "控制设备")
    @PostMapping("/control/device/{deviceId}/function/{functionId}")
    public Rest<String> control(@PathVariable("deviceId") String deviceId,@PathVariable("functionId") String functionId,@RequestBody Map<String, Object> properties){
        String result = drcsCockpitService.control(deviceId,functionId,properties);
        return Rest.ok(result);
    }
}
